<%@ page language="java" contentType="text/html; charset=UTF-8"	pageEncoding="UTF-8"%>
<%@include file="/common/taglib.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>角色管理</title>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/aa.js"></script>
<link rel="stylesheet" href="front/css/common.css" type="text/css" />


</head>
<body>
<html:form action="maintainVehicleAction" method="post">
<input type="hidden" name="callMethod" id="callMethod" value="getroleDataList"/>

<table width="99%" border="0" align="center" cellpadding="3"		cellspacing="1" class="table_style">
		<tr>
			<td width="10%" class="left_title_3"> <input type="hidden"  name="roleID"  id="roleID"/> <input type="text"  name="roleName"  id="roleName"/> </td>
		<td colspan="3" ><input type="button" id="updateButton" onclick="submitRole()" value="增加角色"></td>
		</tr>
</table>

<aa:zone name="roleZone">
	<div id="man_zone">

				<table width="99%" border="0" align="center" cellpadding="3"
					cellspacing="1" class="table_style">
		<tr>
			<td width="10%" class="left_title_3">序号</td>
			<td width="20%" class="left_title_3">角色名称</td>
			<td  class="left_title_3">操作</td>
			
		</tr>
			<nested:iterate id="roleVO" property="roleList" indexId="roleIndex">
				<tr>
					<td><%=roleIndex+1%></td>
					<td><nested:write  property="roleName" /></td>
					<td>
					<logic:notEqual value="1" name="roleVO" property="roleID" >
						<input type="button" onclick="updateRole('<nested:write name="roleVO" property="roleID" />','<nested:write name="roleVO" property="roleName" />')" value="编辑">&nbsp;&nbsp;
						<input type="button" onclick="deleteRole('<nested:write name="roleVO" property="roleID" />')" value="删除">
					</logic:notEqual>
					<logic:equal value="1" name="roleVO" property="roleID" >
						<input type="button" value="编辑" disabled="disabled">&nbsp;&nbsp;
						<input type="button"  value="删除" disabled="disabled">&nbsp;&nbsp;注意：业务员角色不允许修改和删除
					</logic:equal>
					
					</td>
				</tr>
			</nested:iterate>
		
		</table>
		</div>
		</aa:zone>
</html:form>


<script type="text/javascript">
function deleteRole(index){
	if(!confirm("确定要删除此条记录?")){
		return;
	}
	
	$('#roleID').val(index);
	ajaxAnywhere.submitAJAX("deleteRole", "roleZone");
	$('#roleID').val("");
}

function submitRole(){
	if($.trim($('#roleName').val())==""){
		alert("必须输入角色名称");
		return;
	}else{
		ajaxAnywhere.submitAJAX("updateRole", "roleZone");
		$('#roleID').val("");
		$('#roleName').val("");
		$('#updateButton').val("增加角色");
		
	}
	
	
	
	
	
}

function updateRole(x1,x2){
	$('#updateButton').val("更新角色");
	
	$('#roleID').val(x1);
	$('#roleName').val(x2);
	
	
}

AjaxAnywhere.prototype.onAfterResponseProcessing = function () {
	alert("角色维护成功!");
};

ajaxAnywhere.showLoadingMessage = function() {
}
</script>


</body>
</html>